package com.yuandian.po;

import lombok.Data;

import java.util.List;

/**
 * 说明：数据归并配置项
 * @Author yanjun
 * @Date 2022/2/15 11:58
 */
@Data
public class MergeDataConfig {

    /**
     * 归并的数据类型
     */
    private Class<?> clazz;

    /**
     * 待归并的数据集
     */
    private List<?> data;

    /**
     * 归并开始时间
     */
    private String startTime;

    /**
     * 归并结束时间
     */
    private String endTime;

    /**
     * 要归并的字段
     */
    private List<MergeField> mergeFieldList;

    /**
     * 刻度
     */
    private Integer scale;

    /**
     * 时间标签格式化
     */
    private String labelTimeFormatter;

    /**
     * 时间周期字段名
     */
    private String cycleTimeKey;

    private MergeDataConfig() {}

    private MergeDataConfig(Builder builder) {
        this.clazz = builder.clazz;
        this.data = builder.data;
        this.startTime = builder.startTime;
        this.endTime = builder.endTime;
        this.mergeFieldList = builder.mergeFieldList;
        this.scale = builder.scale;
        this.labelTimeFormatter = builder.labelTimeFormatter;
        this.cycleTimeKey = builder.cycleTimeKey;
    }

    public static final class Builder {
        private Class clazz;
        private List<?> data;
        private String startTime;
        private String endTime;
        private List<MergeField> mergeFieldList;
        private Integer scale;
        private String labelTimeFormatter;
        private String cycleTimeKey;

        public Builder(Class clazz, List<?> data, String startTime, String endTime, List<MergeField> mergeFieldList) {
            this.clazz = clazz;
            this.data = data;
            this.startTime = startTime;
            this.endTime = endTime;
            this.mergeFieldList = mergeFieldList;
        }

        public Builder scale(Integer scale) {
            this.scale = scale;
            return this;
        }

        public Builder labelTimeFormatter(String labelTimeFormatter) {
            this.labelTimeFormatter = labelTimeFormatter;
            return this;
        }

        public Builder cycleTimeKey(String cycleTimeKey) {
            this.cycleTimeKey = cycleTimeKey;
            return this;
        }

        public MergeDataConfig build() {
            return new MergeDataConfig(this);
        }
    }
}
